package AssembleExercise;

import java.util.ArrayList;
import java.util.Arrays;

public class HomeWork1 {

    public static void main(String args[])
    {
        ArrayList<News> news = new ArrayList<>();
        for (String s : Arrays.asList("新馆确诊病例超前卫，属的空间打开防火防盗上课了附件是", "男子突然开始就发动机上来看结果深刻理解欧的世界观可是大家")) {
            news.add(new News(s));
        }
        for (int i=news.size()-1;i>=0;i--)
        {
//            System.out.println(news.get(i));
            News news1 = news.get(i);
            System.out.println(processTitle(news1.getTitle()));
        }
    }
    public static String processTitle(String title)
    {
        if(title ==null)
        {
            return "";
        }
        if(title.length()>15)
        {
            return title.substring(0,15)+"...";
        }
        else
        {
            return title;
        }
    }
}


class News {
    private String title;
    private String contents;

    public News(String title) {
        this.title = title;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContents() {
        return contents;
    }

    public void setContents(String contents) {
        this.contents = contents;
    }

    @Override
    public String toString() {
        return "News{" +
                "title='" + title + '\'' +
                '}';
    }
}

